package algorithm;

import java.util.Scanner;

/**
 * create by yongli on 2021-02-28 13:34
 */

public class MRoot {
    static int min=1,max=10,maxLen=0,minLen=0;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int m = scanner.nextInt();
        String big = scanner.next();
        if(m ==1){
            System.out.println(big);
        }
        // 个位数的m次方的x， x < max
        for(int i=1;i<m;i++) {
            max *= 10;
            min *= 10;
        }
        maxLen = String.valueOf(max).length();
        minLen= String.valueOf(min).length();
        StringBuffer sb = new StringBuffer();
        root(big,m,sb);
        System.out.println(new String(sb));
    }

    public static void root(String big,int m,StringBuffer sb){
        int len = big.length();
        if(len <= maxLen){
            int bigInt = Integer.valueOf(big);
            int res = rootSmall(m,bigInt);
            sb.append(res);
            return;
        }else {
            String left = big.substring(0, maxLen-1);
            int leftInt = Integer.valueOf(left);
            // 不够除的情况
            if (leftInt <= min) {
                 left = big.substring(0,maxLen);
                 leftInt = Integer.valueOf(left);
                 int res = rootSmall(m, leftInt);

                 big = big.substring(maxLen+1);
                 sb.append("10");
                 root(big,m,sb);
            } else {
                left = big.substring(0, maxLen - 1);
                String right = big.substring(maxLen - 1);
                leftInt = Integer.valueOf(left);
                System.out.println(leftInt);
                // 位数相同，但是大小未知
                int res = rootSmall(m, leftInt);
                sb.append(res);
                System.out.println(res);
                int gcd = leftInt - mul(res, m);
                // 新数
                big = gcd + right;
                root(big, m, sb);
            }
        }
    }

    public static int rootSmall(int mi,int sum){
        // >1
        for(int i=0;i<10;i++){
            if(mul(i,mi) == sum) return i;
            if(mul(i,mi)<sum && mul(i+1,mi)>sum){
                return i;
            }
        }
        return 9;
    }

    public static int mul(int n,int mi){
        int sum =1;
        for(int i =0;i<mi;i++){
            sum *= n;
        }
        return sum;
    }
}
